package yunhe.biz.impl;

import java.util.ArrayList;
import java.util.HashMap;

import org.apache.ibatis.session.SqlSession;

import yunhe.biz.StorageBiz;
import yunhe.dao.StorageInte;
import yunhe.entity.EmpMsg;
import yunhe.entity.Storage;
import yunhe.util.SqlSessionFactoryUtil;

public class StorageBizImpl implements StorageBiz{
	SqlSession sqlSession=SqlSessionFactoryUtil.getSqlSession();
	StorageInte storageInte=sqlSession.getMapper(StorageInte.class);
	/**
	 * 添加仓库
	 * @param storage
	 * @return
	 */
	public boolean addStorage(Storage storage){
		if (storageInte.addStorage(storage)) {
			sqlSession.commit();
			return true;
		}else {
			return false;
		}
	}
	//删
	/**
	 * 删除仓库
	 * @param storageId
	 * @return
	 */
	public boolean delStorage(String storageId){
		if (storageInte.delStorage(storageId)) {
			sqlSession.commit();
			return true;
		}else {
			return false;
		}
	}
	//改
	/**
	 * 更改仓库
	 * @param storage
	 * @return
	 */
	public boolean updateStorage(Storage storage){
		if (storageInte.updateStorage(storage)) {
			sqlSession.commit();
			return true;
		}else {
			return false;
		}
	}
	//查
	/**
	 * 查询所有仓库
	 * @return
	 */
	public ArrayList<Storage> getAllStorage(HashMap<String,String> searchMap){
		ArrayList<Storage> stoList=storageInte.getAllStorage(searchMap);
		return stoList;
	}
	/**
	 * 分页查询仓库
	 * @param curPage
	 * @param pageSize
	 * @return
	 */
	public ArrayList<Storage> getStoByPage(int curPage, int pageSize){
		ArrayList<Storage> stoList=storageInte.getStoByPage(curPage, pageSize);
		return stoList;
	}
	/**
	 * 查询仓库总条数
	 * @return
	 */
	public int getStoCount(){
		return storageInte.getStoCount();
	}
	/**
	 * 获取仓库负责人
	 * @param workId
	 * @return
	 */
	public EmpMsg getEmpByName(String empName){
		return storageInte.getEmpByName(empName);
	}
}
